package cn.itcast.oa.service.impl;

import java.util.List;

import org.springframework.stereotype.Service;

import cn.itcast.oa.base.BaseDAOimpl;
import cn.itcast.oa.model.Department;
import cn.itcast.oa.service.DepartmentService;

@Service
@SuppressWarnings("unchecked")
public class DepartmentServiceImpl extends BaseDAOimpl<Department> implements DepartmentService{

	/**
	 * 查找顶级部门FROM Department d WHERE d.parent IS NULL
	 */
	@Override
	public List<Department> findTopList() {
		// TODO Auto-generated method stub
		return getSession().createQuery("FROM Department d WHERE d.parent IS NULL").list();
	}

	//查找部门下的子部门FROM Department d WHERE d.parent.id=?
	@Override
	public List<Department> getChildren(Long parentId) {
		// TODO Auto-generated method stub
		return getSession().createQuery("FROM Department d WHERE d.parent.id=?").setParameter(0, parentId).list();
	}

	
}
